//
//  RBBinder.m
//  Master
//
//  Created by Lan on 2017/6/1.
//  Copyright © 2017年 LongCai. All rights reserved.
//

#import "RBBinder.h"
#import "RBCellProtocol.h"

@implementation RBBinder

+ (void)bindCell: (UIView <RBCellProtocol>*)cell withCellModel: (RBCellModel *)cellModel
{
    if ([cell conformsToProtocol:@protocol(RBCellProtocol)] && [cellModel isKindOfClass:[RBCellModel class]])
    {
        if ([cell respondsToSelector:@selector(setCellModel:)])
        {
            [cell setCellModel:cellModel];
        }
    }
}

+ (void)bindView:(UIView <RBCollectionReuseViewProtocol>*)view withGroupHeaderModel:(RBGroupModel *)groupHeaderModel
{
    if ([view conformsToProtocol:@protocol(RBCollectionReuseViewProtocol)] && [groupHeaderModel isKindOfClass:[RBGroupModel class]])
    {
        if ([view respondsToSelector:@selector(setHeaderGroupModel:)])
        {
            [view setHeaderGroupModel:groupHeaderModel];
        }
    }
}

+ (void)bindView:(UIView <RBCollectionReuseViewProtocol>*)view withGroupFooterModel:(RBGroupModel *)groupFooterModel
{
    if ([view conformsToProtocol:@protocol(RBCollectionReuseViewProtocol)] && [groupFooterModel isKindOfClass:[RBGroupModel class]])
    {
        if ([view respondsToSelector:@selector(setFooterGroupModel:)])
        {        
            [view setFooterGroupModel:groupFooterModel];
        }
    }
}

@end
